package BinaryTree;

public class Offer54kthLargest {
    int count=0;
    int res=0;
    public int kthLargest(TreeNode root, int k){
        dfs(root,k);
        return res;
    }

    void dfs(TreeNode root, int k) {
        if(root==null){
            return;
        }
        dfs(root.right,k);
        count++;
        if(count==k){
            res=root.val;
        }
        dfs(root.left,k);
    }
}
